import * as mobx from 'mobx';
import { ListStore } from './listStore';
import { WeaTools } from 'ecCom';

import * as API_MONITOR from '../apis/monitor';


const observable = mobx.observable;
const action = mobx.action;

export class WFMonitorLogStore extends ListStore{
    @observable monitorLogShow = false;
    @observable searchParams = {};

    constructor() {
        super();
        this.title = "监控日志";
        
        this.showMonitorLog = this.showMonitorLog.bind(this);
        this.doSearch = this.doSearch.bind(this);
        this.initDatas = this.initDatas.bind(this);
        this.resetCondition = this.resetCondition.bind(this);
        }

    @action
    initDatas(){
        API_MONITOR.getLogConditionInfo().then((data)=>{
            let condition = data.conditioninfo;
            this.condition = condition;
            this.form.initFormFields(condition);
        })
    }
    doSearch(params = {}){
        // this.monitorLogShow = true;
        let queryParams = {};
        //常用查询条件值
        const searchParamsCommon = this.form.getFormParams();
        //自定义查询条件值
        let searchParamsAd = {};
        
        //拼接查询请求参数
        queryParams = {...this.searchParams, ...searchParamsCommon, ...searchParamsAd, ...queryParams};
        this.loading = true;
        API_MONITOR.getLogSessionkey(queryParams).then((data)=>{
            this.loading = false;
            this.tableStore.getDatas(data.sessionkey, params.current || 1);
        });
    }
    showMonitorLog(bool){
        this.monitorLogShow = bool;
    }
    resetCondition(){
        this.clearFormFields();
    }
}